package de.osflex.touarek.containers
{
	import de.osflex.touarek.util.Config;
	
	import flash.events.Event;
	
	import mx.controls.HTML;
	
	/**
	 * @author Andre Mörke
	 * @class HTMLContainer
	 * @created 20080908
	 * 
	 * Extends the HTML control
	 * to config some properties
	 */

	public class HTMLContainer extends HTML
	{
		private var _runtime:Object;
		private var _location:String;
		
		/**
		 * Sets the ApplicationRuntime to the HTML control
		 * and the location
		 * @param p_runtime Object
		 * @param p_location String
		 */ 
		
		public function HTMLContainer(p_runtime:Object, p_location:String='')
		{
			super();
			this._runtime = p_runtime;
			this._location = p_location.length > 0 ? p_location : Config.HTML_LOCATION;
			this.addEventListener(Event.HTML_DOM_INITIALIZE, domInitializedHandler);
			initHTML();	
		}
		
		/**
		 * Sets the UserAgent for special behaviors
		 * and cachePolicy
		 *		  
		 */
		
		private function initHTML():void
		{
			this.location = this._location;
			this.verticalScrollPolicy = 'off';
			this.horizontalScrollPolicy = 'off';
			this.percentWidth = 100;
			this.percentHeight = 100;		
			this.cachePolicy = 'on';
			this.userAgent = "Mozilla/5.0 (X11; U; Linux i686; en;) AppleWebKit/522.15.5 (KHTML, like Gecko) Version/3.0.3 Safari/522.15.5";
			this.paintsDefaultBackground = false;						 
		}
		
		/**
		 * ApplicationRuntime = HTML controlruntime
		 * 
		 * @param event Event
		 */ 
		
		private function domInitializedHandler(event:Event):void
		{
			this.domWindow.runtime = this._runtime;
		}
		
	}
}